package cn.chenli.job.tool.engine.java;


import javax.tools.SimpleJavaFileObject;
import java.io.File;

public class CharSequenceJavaFileObject  extends SimpleJavaFileObject {

    /**
     * Java源文件的内容
     */
    private CharSequence content;

    /**
     * //uri为类的资源定位符号, 如: com/stone/generate/Hello.java
     * @param javaFilePath:为类的资源定位符号, 如: com/stone/generate/Hello.java
     * @param className：
     * @param content：
     */
    public CharSequenceJavaFileObject(String javaFilePath, String className, CharSequence content) throws Exception {
        super(new File(javaFilePath + className.replace('.', '/') + Kind.SOURCE.extension).toURI(), Kind.SOURCE);
        this.content = content;
    }

    @Override
    public CharSequence getCharContent(boolean ignoreEncodingErrors) {
        return content;
    }
}